﻿namespace ctolua.Models
{
    /// <summary>
    /// 玩家组
    /// </summary>
    public class MRoleGroup
    {
        /// <summary>
        /// 玩家组
        /// </summary>
        public RoleGroup roleGroup { get; set; }
        /// <summary>
        /// 是否存在
        /// </summary>
        public bool? is_null => game_api.role_group_is_exist(this.roleGroup);
        public MRoleGroup(RoleGroup roleGroup)
        {
            this.roleGroup = roleGroup;
        }
        /// <summary>
        /// 将玩家添加到玩家组
        /// </summary>
        /// <param name="r"></param>
        public void add(Role r)
        {
            game_api.add_role_to_group(r, this.roleGroup);
        }
        /// <summary>
        /// 玩家组中删除玩家
        /// </summary>
        /// <param name="r"></param>
        public void del(Role r)
        {
            game_api.rem_role_from_group(r, this.roleGroup);
        }

        /// <summary>
        /// 获取某玩家敌对玩家组
        /// </summary>
        /// <param name="role ">  玩家   </param>
        /// <returns>玩家组</returns>
        public static MRoleGroup get_enemy_ids_by_role(Role role) => new MRoleGroup(game_api.get_enemy_ids_by_role(role));
        /// <summary>
        /// 获取获胜玩家组
        /// </summary>
        /// <returns>玩家组</returns>
        public static MRoleGroup get_victorious_role_ids => new MRoleGroup(game_api.get_victorious_role_ids());
        /// <summary>
        /// 获取失利玩家组
        /// </summary>
        /// <returns>玩家组</returns>
        public static MRoleGroup get_defeated_role_ids => new MRoleGroup(game_api.get_defeated_role_ids());
        /// <summary>
        /// 所有玩家
        /// </summary>
        /// <returns>玩家组</returns>
        public static MRoleGroup get_all_role_ids => new MRoleGroup(game_api.get_all_role_ids());
        /// <summary>
        /// 阵营所有玩家
        /// </summary>
        /// <param name="camp ">  阵营对象   </param>
        /// <returns>玩家组</returns>
        public static MRoleGroup get_role_ids_by_camp(Camp camp) => new MRoleGroup(game_api.get_role_ids_by_camp(camp));
        /// <summary>
        /// 特定类型玩家
        /// </summary>
        /// <param name="role_type ">  玩家类型   </param>
        /// <returns>玩家组</returns>
        public static MRoleGroup get_role_ids_by_type(int? role_type) => new MRoleGroup(game_api.get_role_ids_by_type(role_type));
        /// <summary>
        /// 同盟玩家
        /// </summary>
        /// <param name="role ">  玩家   </param>
        /// <returns>玩家组</returns>
        public static MRoleGroup get_ally_ids_by_role(Role role) => new MRoleGroup(game_api.get_ally_ids_by_role(role));
        /// <summary>
        /// 返回玩家列表
        /// </summary>
        /// <returns></returns>
        public List<Role> pick()
        {
            List<Role> lua_table = new List<Role>();
            for (int i = 1; i < py.python_len(this.roleGroup); i++)
            {
                Role iter_player = py.python_index(this.roleGroup, i - 1);
                lua_table.Add(iter_player);
            }
            return lua_table;
        }


    }
}
